import { createApp } from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";
import "element-plus/dist/index.css";
import ElementPlus from "element-plus";
import "./assets/css/normalize.scss";
// import "./assets/css/common.scss";
import "./assets/css/layout.scss";
import TablePlus from './../packages'

import * as ElementPlusIconsVue from '@element-plus/icons-vue'

// 全局引入样式
const app = createApp(App)
// 统一注册el-icon图标
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}

app.directive('has', {
  beforeMount: function (el, binding) {
    let actionList: string[]  = JSON.parse(localStorage.getItem("actionList") || "[]") || [];
    let value = binding.value;
    let hasPermission = actionList.includes(value)
    if (binding.value && !hasPermission) {
      el.style = 'display:none';
      setTimeout(() => {
        el.parentNode.removeChild(el);
      }, 0)
    }
  }
})

app.use(router)
  .use(store)
  .use(ElementPlus, { zIndex: 3000 })
  .use(TablePlus)
  .mount("#app");
